{extend name="common/layout" /}

{block name="title"}商品管理{/block}
{block name="content"}
<div id="content">

    <div class="page-header">
        <div class="container-fluid">
            <div class="pull-right">
                <button type="submit" form="form-create" data-toggle="tooltip" title="保存" class="btn btn-primary">
                    <i class="fa fa-save"></i>
                </button>
                <a href="{:url('index')}" data-toggle="tooltip" title="取消" class="btn btn-default">
                    <i class="fa fa-reply"></i>
                </a>
            </div>
            <h1>商品{if condition="is_null($id)"}创建{else/}修改{/if}</h1>
            <ul class="breadcrumb">
                <li>
                    <a href="/back/site/index.html">首页</a>
                </li>
                <li>
                    <a href="/back/brand/index.html">商品</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <i class="fa fa-pencil"></i>
                    商品{if condition="is_null($id)"}创建{else/}修改{/if}
                </h3>
            </div>
            <div class="panel-body">
                <form action="{:url('set')}" method="post" enctype="multipart/form-data" id="form-create"
                      class="form-horizontal">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#tab-general" data-toggle="tab">基本信息</a>

                        </li>
                        <li>
                            <a href="#tab-extra" data-toggle="tab">扩展信息</a>
                        </li>
                        <li>
                            <a href="#tab-des" data-toggle="tab">描述</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab-general">
                            {if condition="!is_null($id)"}

                            <input type="hidden" name="id" value="{$id}">
                            {/if}

                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-title">名称</label>
                                <div class="col-sm-10">
                                    <input type="text" name="title" value="{$data['title']|default=''}" placeholder="名称"
                                           id="input-title" class="form-control"/>

                                    {if condition="isset($message['title'])"}
                                    <label class="text-danger" id="input-title-error" for="input-title">{$message['title']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="input-upc">条码</label>
                                <div class="col-sm-10">
                                    <input type="text" name="upc" value="{$data['upc']|default=''}" placeholder="条码"
                                           id="input-upc" class="form-control"/>

                                    {if condition="isset($message['upc'])"}
                                    <label class="text-danger" id="input-upc-error" for="input-upc">{$message['upc']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="col-sm-2 control-label" for="input-image">缩略图</label>
                                <div class="col-sm-10">
                                    <input type="text" name="image" value="{$data['image']|default=''}" placeholder="缩略图"
                                           id="input-image" class="form-control"/>

                                    {if condition="isset($message['image'])"}
                                    <label class="text-danger" id="input-image-error" for="input-image">{$message['image']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group  required">
                                <label class="col-sm-2 control-label" for="input-inventory">库存</label>
                                <div class="col-sm-3">
                                    <input type="text" name="inventory" value="{$data['inventory']|default=''}" placeholder="库存"
                                           id="input-inventory" class="form-control "  />

                                    {if condition="isset($message['inventory'])"}
                                    <label class="text-danger" id="input-inventory-error" for="input-inventory">{$message['inventory']}</label>

                                    {else /}

                                    {/if}

                                </div>
                                <div class="col-sm-4 text-left">
                                    <select name="unit_id" id="input-unit_id" class="form-control">
                                        <option value="0">未选择</option>
                                        {foreach $unit_list as $unit }
                                        <option value="{$unit['id']}">{$unit['title']}</option>
                                        {/foreach}
                                    </select>




                                </div>
                                <div class="col-sm-4  ">




                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="col-sm-2 control-label" for="input-mininum">最小起售</label>
                                <div class="col-sm-10">
                                    <input type="text" name="mininum" value="{$data['mininum']|default=''}" placeholder="最小起售"
                                           id="input-mininum" class="form-control"/>

                                    {if condition="isset($message['mininum'])"}
                                    <label class="text-danger" id="input-mininum-error" for="input-mininum">{$message['mininum']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-price">售价</label>
                                <div class="col-sm-10">
                                    <input type="text" name="price" value="{$data['price']|default=''}" placeholder="售价"
                                           id="input-price" class="form-control"/>

                                    {if condition="isset($message['price'])"}
                                    <label class="text-danger" id="input-price-error" for="input-price">{$message['price']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="col-sm-2 control-label" for="input-price_orign">原价</label>
                                <div class="col-sm-10">
                                    <input type="text" name="price_orign" value="{$data['price_orign']|default=''}" placeholder="原价"
                                           id="input-price_orign" class="form-control"/>

                                    {if condition="isset($message['price_orign'])"}
                                    <label class="text-danger" id="input-price_orign-error" for="input-price_orign">{$message['price_orign']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>










                        </div>
                        <div class="tab-pane  " id="tab-extra">

                            <div class="form-group required">
                                <label class="col-sm-2 control-label"  >配送支持</label>
                                <div class="col-sm-1">
                                    <label for="input-is_shopping_yes">  <input type="radio" name="is_shopping" value="{$data['is_shopping']|default='1'}"
                                                                                id="input-is_shopping_yes" class="form-control" checked/>是</label>
                                </div>
                                <div class="col-sm-1">
                                    <input type="radio" name="is_shopping" value="{$data['is_shopping']|default='0'}"
                                           id="input-is_shopping_no" class="form-control"/><label for="input-is_shopping_no">否</label>


                                </div>
                            </div>
                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-date_avaliable">起送时间</label>
                                <div class="col-sm-10">
                                    <input type="text" name="date_avaliable" value="{$data['date_avaliable']|default=''}" placeholder="起送时间"
                                           id="input-date_avaliable" class="form-control bootstrap-datetimepicker-widget"/>

                                    {if condition="isset($message['date_avaliable'])"}
                                    <label class="text-danger" id="input-date_avaliable-error" for="input-date_avaliable">{$message['date_avaliable']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-status">状态</label>
                                <div class="col-sm-10">
                                    <!--<input type="text" name="status" value="{$data['status']|default=''}" placeholder="状态"-->
                                    <!--id="input-status" class="form-control"/>-->
                                    <select name="status" id="status" class="form-control">
                                        <option value="0">下架</option>
                                        <option value="1">上架</option>
                                    </select>

                                    {if condition="isset($message['status'])"}
                                    <label class="text-danger" id="input-status-error" for="input-status">{$message['status']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-brand_id">品牌</label>
                                <div class="col-sm-10">


                                    <select name="unit_id" id="input-brand_id" class="form-control">
                                        <option value="0">未选择</option>
                                        {foreach $brand_list as $brand }
                                        <option value="{$brand['id']}">{$brand['title']}</option>
                                        {/foreach}
                                    </select>



                                    {if condition="isset($message['brand_id'])"}
                                    <label class="text-danger" id="input-brand_id-error" for="input-brand_id">{$message['brand_id']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>

                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-category_id">类别</label>
                                <div class="col-sm-10">


                                    <select name="unit_id"  name="category_id" id="input-category_id" class="form-control">

                                        {foreach $category_list as $category }
                                        <option value="{$category['id']}">{:str_repeat('&nbsp;',$category['level']*4)}{$category['title']}</option>
                                        {/foreach}
                                    </select>

                                    {if condition="isset($message['category_id'])"}
                                    <label class="text-danger" id="input-category_id-error" for="input-category_id">{$message['category_id']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>
                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-sort">排序</label>
                                <div class="col-sm-10">
                                    <input type="text" name="sort" value="{$data['sort']|default=''}" placeholder="排序"
                                           id="input-sort" class="form-control"/>

                                    {if condition="isset($message['sort'])"}
                                    <label class="text-danger" id="input-sort-error" for="input-sort">{$message['sort']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>






                        </div>
                        <div class="tab-pane  " id="tab-des">


                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-descrition">描述</label>
                                <div class="col-sm-10">

                                    <textarea name="descrition" id="input-descrition" class="form-control">
                                        {$data['descrition']|default=''}
                                    </textarea>

                                    {if condition="isset($message['descrition'])"}
                                    <label class="text-danger" id="input-descrition-error" for="input-descrition">{$message['descrition']}</label>

                                    {else /}

                                    {/if}

                                </div>
                            </div>




                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--日历插件-->
<link rel="stylesheet" href="__STATIC__/datetimepicker/bootstrap-datetimepicker.min.css">
<script src="__STATIC__/datetimepicker/moment.js"></script>
<script src="__STATIC__/datetimepicker/bootstrap-datetimepicker.min.js"></script>

<!--富文本编辑器的引入-->

<script src="__STATIC__/ckeditor/ckeditor.js"></script>
<script src="__STATIC__/ckeditor/lang/zh-cn.js"></script>
<script src="__STATIC__/ckeditor/config.js"></script>

<script type="text/javascript">

    $(function () {
        $('.bootstrap-datetimepicker-widget').datetimepicker({
            format: 'YYYY-MM-DD HH:mm'
        });

        //加载编辑器
        CKEDITOR.replace('input-descrition',{ toolbar :
            [
                //加粗     斜体，     下划线      穿过线      下标字        上标字
                ['Bold','Italic','Underline','Strike','Subscript','Superscript'],
                // 数字列表          实体列表            减小缩进    增大缩进
                ['NumberedList','BulletedList','-','Outdent','Indent'],
                //左对 齐             居中对齐          右对齐          两端对齐
                ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                //超链接  取消超链接 锚点
                ['Link','Unlink','Anchor'],
                //图片    flash    表格       水平线            表情       特殊字符        分页符
                ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
                '/',
                // 样式       格式      字体    字体大小
                ['Styles','Format','Font','FontSize'],
                //文本颜色     背景颜色
                ['TextColor','BGColor'],
                //全屏           显示区块
                ['Maximize', 'ShowBlocks','-']
            ]});
    })

</script>
{/block}




